W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
Byteasar is a famous safe-cracker, who renounced his criminal activity and got into testing and certifying anti-burglary devices. He has just received a new kind of strongbox for tests: a combinatorial safe. A combinatorial safe is something different from a combination safe, even though it is opened with a rotary dial. The dial can be set in different positions, numbered from 0 to . Setting the dial in some of these positions opens the safe, while in others it does not. And here is the combinatorial property, from which the name comes from: if and are opening positions, then so is too; note that is holds for as well.
Byteasar tried different positions of the dial: . The positions did not open the safe, only the last position did. Byteasar is already tired from checking these positions and has thus absolutely no intention of trying the remaining ones. He would like to know however, based on what he already knows about the positions he tried, what is the maximum possible number of positions that open the safe. Help him by writing an appropriate program!
The first line of the standard input gives two integers and , separated by a single space, , . The second line holds different integers, also separated by single spaces, , . You can assume that the input data correspond to a certain combinatorial safe that complies with the description above.
In tests worth approximately 70% of the points it holds that . In some of those tests, worth approximately 20% of the points, the following conditions hold in addition: and .
Your program should print out to the first and only line of the standard output a single integer: the maximum number of the dial's positions that can open the safe.
For the input data:
42 5 28 31 10 38 24
the correct result is:
14
Task author: Marian M. Kedzierski.